package com.xuecheng.content.api;

import com.xuecheng.base.exception.ValidationGroups;
import com.xuecheng.base.resutl.RestResponse;
import com.xuecheng.content.model.dto.AddCourseTeacherDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.ICourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * @ClassName: CourseTeacherController
 * @Description: 课程教师接口
 * @Author: Huang Yao
 * @CreateTime: 2024-06-26 10:29
 * @Version: 1.0
 **/
@Api(tags = "课程教师接口")
@RestController
@Slf4j
public class CourseTeacherController {
    @Autowired
    private ICourseTeacherService iCourseTeacherService;

    @GetMapping("/courseTeacher/list/{courseId}")
    @ApiOperation("查询课程相关教师接口")
    public List<CourseTeacher> getCourseTeacher(@PathVariable Long courseId){
        // TODO 登录信息中获取机构id
        //机构id，由于认证系统没有上线暂时硬编码
        Long companyId = 1232141425L;
        return iCourseTeacherService.getCourseTeacher(companyId,courseId);
    }

    @ApiOperation("添加课程相关教师接口")
    @PostMapping("/courseTeacher")
    public RestResponse saveCourseTeacher(@RequestBody @Validated({ValidationGroups.Inster.class}) AddCourseTeacherDto addCourseTeacherDto){
        // TODO 登录信息中获取机构id
        //机构id，由于认证系统没有上线暂时硬编码
        Long companyId = 1232141425L;
        iCourseTeacherService.saveCourseTeacher(addCourseTeacherDto,companyId);
        return RestResponse.success();
    }

    @ApiOperation("删除课程相关教师接口")
    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    public RestResponse deleteCourseTeacher(@PathVariable @NotEmpty Long courseId, @PathVariable @NotEmpty Long teacherId){
        log.info("课程id:{},课程教师id:{}",courseId,teacherId);
        return iCourseTeacherService.deleteCourseTeacher(courseId,teacherId);
    }
}
